package com.fun.demo.fun.design;

//将抽象部分与它的实现部分分离，使它们可以独立变化。
public class Bridge {
}

interface DrawAPI {
    void drawCircleB(int radius, int x, int y);
}

class RedCircleB implements DrawAPI {
    @Override
    public void drawCircleB(int radius, int x, int y) {
        System.out.println("Drawing CircleB[ color: red, radius: " + radius + ", x: " + x + ", " + y + "]");
    }
}

class GreenCircleB implements DrawAPI {
    @Override
    public void drawCircleB(int radius, int x, int y) {
        System.out.println("Drawing CircleB[ color: green, radius: " + radius + ", x: " + x + ", " + y + "]");
    }
}

abstract class SquareB {
    protected DrawAPI drawAPI;

    protected SquareB(DrawAPI drawAPI) {
        this.drawAPI = drawAPI;
    }

    public abstract void draw();
}

class CircleB extends SquareB {
    private int x, y, radius;

    public CircleB(int x, int y, int radius, DrawAPI drawAPI) {
        super(drawAPI);
        this.x = x;
        this.y = y;
        this.radius = radius;
    }

    @Override
    public void draw() {
        drawAPI.drawCircleB(radius, x, y);
    }
}

